class GMHomeModel {
  int? status;
  String? msg;
  List<GMHomeData>? data;

  GMHomeModel({this.status, this.msg, this.data});

  GMHomeModel.fromJson(Map<String, dynamic> json) {
    status = json['status'];
    msg = json['msg'];
    if (json['data'] != null) {
      data = <GMHomeData>[];
      json['data'].forEach((v) {
        data!.add(GMHomeData.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['status'] = status;
    data['msg'] = msg;
    if (this.data != null) {
      data['data'] = this.data!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class GMHomeData {
  String? id;
  String? userId;
  int? genre;
  String? releaseTime;
  String? remark;
  String? sex;
  String? province;
  String? city;
  String? district;
  String? fileJson;
  List<GMHomeFiles>? files;
  String? state;
  String? nick;
  String? age;
  String? vaccine;
  String? worm;
  String? sterilization;
  String? source;
  String? demand;
  String? story;
  String? location;
  String? phone;
  String? wechat;

  GMHomeData(
      {this.id,
      this.userId,
      this.genre,
      this.releaseTime,
      this.remark,
      this.sex,
      this.province,
      this.city,
      this.district,
      this.fileJson,
      this.files,
      this.state,
      this.nick,
      this.age,
      this.vaccine,
      this.worm,
      this.sterilization,
      this.source,
      this.demand,
      this.story,
      this.location,
      this.phone,
      this.wechat});

  GMHomeData.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    userId = json['userId'];
    genre = json['genre'];
    releaseTime = json['releaseTime'];
    remark = json['remark'];
    sex = json['sex'];
    province = json['province'];
    city = json['city'];
    district = json['district'];
    fileJson = json['fileJson'];
    if (json['files'] != null) {
      files = <GMHomeFiles>[];
      json['files'].forEach((v) {
        files!.add(GMHomeFiles.fromJson(v));
      });
    }
    state = json['state'];
    nick = json['nick'];
    age = json['age'];
    vaccine = json['vaccine'];
    worm = json['worm'];
    sterilization = json['sterilization'];
    source = json['source'];
    demand = json['demand'];
    story = json['story'];
    location = json['location'];
    phone = json['phone'];
    wechat = json['wechat'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['userId'] = userId;
    data['genre'] = genre;
    data['releaseTime'] = releaseTime;
    data['remark'] = remark;
    data['sex'] = sex;
    data['province'] = province;
    data['city'] = city;
    data['district'] = district;
    data['fileJson'] = fileJson;
    if (files != null) {
      data['files'] = files!.map((v) => v.toJson()).toList();
    }
    data['state'] = state;
    data['nick'] = nick;
    data['age'] = age;
    data['vaccine'] = vaccine;
    data['worm'] = worm;
    data['sterilization'] = sterilization;
    data['source'] = source;
    data['demand'] = demand;
    data['story'] = story;
    data['location'] = location;
    data['phone'] = phone;
    data['wechat'] = wechat;
    return data;
  }

  String locationValue() {
    return "$city-$district";
  }

  String publicTimeValue() {
    List<String> times = releaseTime!.split(' ');
    if (times.length == 2) {
      String value = times.first;
      return "发布时间：$value";
    }
    return releaseTime!;
  }

  List<String> huiFangTags() {
    String myString = demand!;
    if (myString.isNotEmpty) {
      String lastCharacter = myString.substring(myString.length - 1);
      if (lastCharacter == "-") {
        String removedLastCharacter =
            myString.substring(0, myString.length - 1);
        return removedLastCharacter.split('-');
      }
    }
    return [];
  }
}

class GMHomeFiles {
  String? url;
  int? rank;
  String? type;
  String? width;
  String? height;
  String? status;

  GMHomeFiles(
      {this.url, this.rank, this.type, this.width, this.height, this.status});

  GMHomeFiles.fromJson(Map<String, dynamic> json) {
    url = json['url'];
    rank = json['rank'];
    type = json['type'];
    width = json['width'];
    height = json['height'];
    status = json['status'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['url'] = url;
    data['rank'] = rank;
    data['type'] = type;
    data['width'] = width;
    data['height'] = height;
    data['status'] = status;
    return data;
  }
}
